//
//  LCZOneCell.m
//  PersonalNews
//
//  Created by dllo on 15/11/30.
//  Copyright © 2015年 changshuhua. All rights reserved.
//

#import "LCZOneCell.h"
#define WIDTH [UIScreen mainScreen].bounds.size.width
#define HEIGHT [UIScreen mainScreen].bounds.size.height
#define TABAR 44
#define HEADERHIHT 64


@implementation LCZOneCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createCell];
    }
    return self;
}


- (void)createCell{
    self.imgsrcImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.imgsrcImageView];
       
    self.titleLabel = [[UILabel alloc] init];
    [self.contentView addSubview:self.titleLabel];
    self.titleLabel.font  = [UIFont systemFontOfSize: 0.04589371980676 * WIDTH];
    
    self.digestLabel = [[UILabel alloc] init];
    [self.contentView addSubview:self.digestLabel];
    self.digestLabel.font = [UIFont systemFontOfSize:WIDTH * 0.04106280193237];
    self.digestLabel.textColor = [UIColor grayColor];
    
    self.replyCountLabel = [[UILabel alloc] init];
    self.replyCountLabel.font = [UIFont systemFontOfSize:WIDTH * 0.03381642512077];
    self.replyCountLabel.layer.borderColor = [UIColor lightGrayColor].CGColor;
    self.replyCountLabel.layer.borderWidth = 1;
    self.replyCountLabel.layer.cornerRadius = WIDTH * 0.0242;
    [self.contentView addSubview:self.replyCountLabel];
    self.replyCountLabel.textAlignment = NSTextAlignmentCenter;
    
    self.grayView = [[LCZBaseView alloc]init];
    [self.contentView addSubview:self.grayView];

   
}


- (void)awakeFromNib {
    
}

- (void)layoutSubviews{
    [super layoutSubviews];
    self.imgsrcImageView.frame = CGRectMake(WIDTH * 0.0242, WIDTH * 0.0242 + 5,  WIDTH * 0.2415 + 20,  WIDTH * 0.2415);
    self.titleLabel.frame = CGRectMake( WIDTH * 0.2899 + 20,  WIDTH * 0.0266, WIDTH * 0.676 - 20, WIDTH * 0.09662 + 20);
    self.digestLabel.frame = CGRectMake( WIDTH * 0.2899, WIDTH * 0.12, WIDTH * 0.676, WIDTH * 0.12077 * 3);
    self.replyCountLabel.frame = CGRectMake(WIDTH * 0.773 - 20, WIDTH * 0.2415,  WIDTH * 0.1932 + 20, WIDTH * 0.036231884);
    
    self.grayView.frame = CGRectMake(0, self.contentView.frame.size.height - 4, self.contentView.frame.size.width, 4);
    self.grayView.backgroundColor = [UIColor colorWithRed:0.88 green:0.89 blue:0.9 alpha:1];
    
    
}
- (void)getDate:(New *)news{
    self.titleLabel.numberOfLines = 0;
    self.titleLabel.text = news.title;
    [self.titleLabel sizeToFit];
    
    self.digestLabel.numberOfLines = 0;
    self.digestLabel.text = news.digest;
    [self.digestLabel sizeToFit];
    NSString *str = [NSString stringWithFormat:@"%@%@", news.replyCount, news.TAGS];
    self.replyCountLabel.text = str;
    [self.imgsrcImageView sd_setImageWithURL:[NSURL URLWithString:news.imgsrc]placeholderImage:[UIImage imageNamed:@"0.jpg"]];
    
    
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
